﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bunian.Core.BusinessObjects;

namespace Bunian.Core
{
    public static class BeneficiaryExtensions
    {
        public static bool IsTender<T>(this IBeneficiary Beneficiary) where T : Tender
        {
            foreach (Tender tend in Beneficiary.BeneficiaryTenders)
            {
                if (tend is T)
                {
                    return true;
                }
            }

            return false;
        }

        public static T GetTender<T>(this IBeneficiary Beneficiary) where T : Tender
        {
            foreach (Tender tend in Beneficiary.BeneficiaryTenders)
            {
                if (tend is T)
                {
                    return (T)tend;
                }
            }

            return null;
        }
    }
}
